const app = getApp();
Page({
  data: {
    focus: false,
    inputValue: '',
    respData: '',
  },
  bindDateChange: function (e) {
    this.setData({
      date: e.detail.value
    })
  },
  bindTimeChange: function (e) {
    this.setData({
      time: e.detail.value
    })
  },
  onLoad: function (options) {
    var that = this;
    var openId = wx.getStorageSync('openId');
    var orgId = wx.getStorageSync('orgId');
    var memNum = wx.getStorageSync('memNum');
    // wx.hideKeyboard();
    this.setData({
      openId: openId,
      memberNum: memNum,
      orgId: orgId
    });
    wx.showLoading({
      title: '数据加载中'
    });
    this.requestData(openId,function () {
      that.setData({
        introduce: that.data.respData.introduce,
        address: that.data.respData.site
      })
    })
    //请求后台数据
  },
  requestData: function (openId,callback) {
    var that = this;
    wx.request({
      url: app.globalData.mpurl + 'user/getInfo',
      method: "GET",
      data: {
        openId: openId,
        memberNum: this.data.memberNum,
        oid: this.data.orgId
      },
      success: function (res) {
        res = res.data;
        console.log(res);
        if (res.code == '00') {
          that.setData({ respData: res.data });
        } else {
          wx.showModal({
            title: '提示',
            content: '获取信息失败',
            showCancel: false,
          })
        }
      },
      fail: function (res) {
        wx.showModal({
          title: '提示',
          content: "系统异常，请稍候再试",
          showCancel: false
        })
      },
      complete: function () {
        wx.hideLoading();
        callback();
      }
    });
  },
  calling: function (e) {
    var mobileNum = e.currentTarget.dataset.mobile;
    wx.makePhoneCall({
      phoneNumber: mobileNum,
      success: function () {
        console.log("拨打电话成功！")
      },
      fail: function () {
        console.log("拨打电话失败！")
      }
    })
  },
  bindTextAreaBlur: function (e) {
    console.log(e.detail.value)
  },
  onReady: function () {
  
  },
  onShow: function (e) {
    var memName = wx.getStorageSync('memName');
    if (memName == null) {
      memName = '手机群录';
    }
    wx.setNavigationBarTitle({
      title: memName,
    })
  },
  changeNavi: function () {
    wx.setNavigationBarColor({
      frontColor: '#ffffff',
      backgroundColor: '#ff0000',
      animation: {
        duration: 400,
        timingFunc: 'easeIn'
      }
    })
  },
  onShareAppMessage: function () {
    return {
      title: '手机群录',
      // imageUrl: 'http://sta.haois.me/common/img/shareapp.png',
      path: '/pages/shareMem/share?memNum=' + this.data.respData.memberNum,
      success: function (res) {
        console.log('转发成功');
      },
      fail: function (res) {
        console.log('转发失败');
      }
    }

  }
})
